var taskHanderJsScript;
var wn_wm_jsScript;
var _baseURL;
var _uid;
var lgAction=false;
function initallWebMessage(uid,serverurl)
{
	 _baseURL=serverurl;
     _uid=uid;
	lgAction=window.setInterval("doLogin()",3000);
}

function doLogin()
{
	window.clearInterval(lgAction);
    initallTaskHanderJs();
}

function initallTaskHanderJs()
{
	var taskHanderJs = document.getElementById("taskHanderJs");
	var head = document.getElementsByTagName('head').item(0);
	if(taskHanderJs) head.removeChild(taskHanderJs);
    taskHanderJsScript = document.createElement('script');
    taskHanderJsScript.onreadystatechange=taskHanderJsScriptLoaded;
    taskHanderJsScript.src =_baseURL+"/worknet_workspace/js/wn_common.js";
    taskHanderJsScript.type = 'text/javascript';
    taskHanderJsScript.id = "taskHanderJs";
    head.appendChild(taskHanderJsScript);
}
function taskHanderJsScriptLoaded()
{
  
  	if (taskHanderJsScript.readyState=='loaded')
	{
	  	initallWNWMJs();
	}  	
}

function initallWNWMJs()
{
	var wn_wm_js = document.getElementById("wn_wm_js");
	var head = document.getElementsByTagName('head').item(0);
	if(wn_wm_js) head.removeChild(wn_wm_js);
    wn_wm_jsScript = document.createElement('script');
    wn_wm_jsScript.onreadystatechange=wn_wm_jsScriptLoaded;
    wn_wm_jsScript.src =_baseURL+"/worknet_workspace/js/wn_wm_impl.js";
    wn_wm_jsScript.type = 'text/javascript';
    wn_wm_jsScript.id = "taskHanderJs";
    head.appendChild(wn_wm_jsScript);
}
function wn_wm_jsScriptLoaded()
{
  
  	if (wn_wm_jsScript.readyState=='loaded')
	{
	  	initallWebMessageImpl(_uid,_baseURL);
	}  	
}
